import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'
import workbenches from '../views/Workbenches.vue'  //引入工作台路由组件
import Communitymanagement from '../views/Communitymanagement.vue'  //引入社区管理路由组件
import AddCommunity from '../views/AddCommunity.vue'   //引入添加社区路由组件
import BuildingManagement from '../views/BuildingManagement.vue'


Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'home',
        component: HomeView
    },
    {
        path: '/about',
        name: 'about',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue'),
        meta:{
            auth:true
        },
        children: [
            {
                // 工作台
                path: 'workbenches',
                component: workbenches
            },
            {
                // 社区管理
                path: 'communitymanagement',
                component: Communitymanagement
            },
            {
                // 添加社区
                path: 'AddCommunity',
                component: AddCommunity
            },
            {
                // 楼宇管理
                path: 'BuildingManagement',
                component: BuildingManagement
            },
            {
                // 添加楼宇
                path: 'BatchAdd',
                name: 'BatchAdd',
                component: () => import('../views/BatchAdd.vue')
            },
            {
                // 房屋管理
                path: 'HousingManagement',
                component: () => import('../views/HousingManagement.vue')
            },
            {
                // 房屋批量导入
                path: 'ImportData',
                component: () => import('../views/ImportData.vue')
            },
            {
                // 房屋批量添加
                path: 'Batchadditionofhouses',
                component: () => import('../views/Batchadditionofhouses.vue')
            },
            {
                // 添加房屋
                path: 'Addahouse',
                component: () => import('../views/Addahouse.vue')
            },
            {
                path: 'Addahousessss',
                component: () => import('../views/Addahousessss.vue')
            },
            {
                // 绑定业主
                path: 'Ownerbinding',
                component: () => import('../views/Ownerbinding.vue')
            },
            {
                // 查看信息
                path: 'Housinginformation',
                // redirect: '/about/Housinginformation/OwnerInformation',
                component: () => import('../views/Housinginformation.vue'),
                children: [
                    {
                        // 业主信息
                        path: 'OwnerInformation',
                        component: () => import('../views/OwnerInformation.vue')
                    },
                    {
                        // 房屋信息
                        path: 'Houseinformation',
                        component: () => import('../views/Houseinformation.vue')
                    },
                    {
                        // 成员信息
                        path: 'Memberinformation',
                        component: () => import('../views/Memberinformation.vue')
                    },
                    {
                        // 储藏室信息
                        path: 'StorageRoomInformation',
                        component: () => import('../views/StorageRoomInformation.vue')
                    },
                    {
                        // 车位信息
                        path: 'Parkingspaceinformation',
                        component: () => import('../views/Parkingspaceinformation.vue')
                    },
                ]
            },
            {
                // 商铺管理
                path: 'Shopmanagement',
                component: () => import('../views/Shopmanagement.vue')
            },
            {
                // 绑定业主
                path:'BingdingOwner',
                component: () => import('../views/BingdingOwner.vue')
            },
            {
                // 商铺批量添加导入
                path: 'Addbulkimportofshops',
                component: () => import('../views/Addbulkimportofshops.vue')
            },
            {
                // 商铺批量添加
                path: 'Batchadditionofshops',
                component: () => import('../views/Batchadditionofshops.vue')
            },
            {
                // 添加商铺
                path: 'Addshop',
                component: () => import('../views/Addshop.vue')
            },

            {
                // 车位管理
                path: 'Parkingspacemanagement',
                redirect: '/about/Parkingspacemanagement/Parkinglotmanagrement',
                component: () => import('../views/Parkingspacemanagement'),
                children: [
                    {
                        // 车位管理
                        path: 'Parkinglotmanagrement',
                        component: () => import('../views/Parkinglotmanagrement.vue')
                    },
                    {
                        // 车库管理
                        path: 'Garagemanagement',
                        component: () => import('../views/Garagemanagement.vue')
                    }
                ]
            },
            {
                // 车位添加批量导入
                path: 'Batchimportofparkingspaceaddition',
                component: () => import('../views/Batchimportofparkingspaceaddition.vue')
            },
            {
                // 添加车位
                path: 'Addparkingspace',
                component: () => import('../views/Addparkingspace.vue')
            },
            {
                // 储藏室管理
                path: 'Storageroommanagement',
                component: () => import('../views/Storageroommanagement.vue')
            },
            {
                // 储藏室批量导入
                path: 'Batchimportofstorageroom',
                component: () => import('../views/Batchimportofstorageroom.vue')
            },
            {
                // 储藏室批量添加
                path: 'Batchadditionofstorageroom',
                component: () => import('../views/Batchadditionofstorageroom.vue')
            },
            {
                // 添加储藏室
                path: 'Addstorageroom',
                component: () => import('../views/Addstorageroom.vue')
            },
            {
                // 物业通知
                path: 'PropertyNotice',
                component: () => import('../views/PropertyNotice.vue')
            },
            {
                // 添加物业通知
                path: 'AddNotification',
                component: () => import('../views/AddNotification.vue')
            },
            {
                // 业主报修
                path: 'Ownersreportrepairs',
                component: () => import('../views/Ownersreportrepairs.vue')
            },
            {
                // 投诉建议
                path: 'Complaintsandsuggestions',
                component: () => import('../views/Complaintsandsuggestions.vue')
            },
            {
                // 内部工单
                path: 'InternalWorkOrder',
                component: () => import('../views/InternalWorkOrder.vue')
            },
            {
                // 添加工单
                path: 'Addinternalworkorder',
                component: () => import('../views/Addinternalworkorder.vue')
            },
            {
                // 访客邀请
                path: 'Visitorinvitation',
                component: () => import('../views/Visitorinvitation.vue')
            },
            {
                // 业主装修
                path: 'Homeownerdecoration',
                component: () => import('../views/Homeownerdecoration.vue')
            },
            {
                // 添加装修申请
                path: 'Adddecorationapplication',
                component: () => import('../views/Adddecorationapplication.vue')
            },
            {
                // 住户管理
                path: 'Residentmanagement',
                component: () => import('../views/Residentmanagement.vue')
            },
            {
                // 住户批量导入
                path: 'Batchimportofresidents',
                component: () => import('../views/Batchimportofresidents.vue')
            },
            {
                // 业主管理
                path: 'Ownermanagement',
                component: () => import('../views/Ownermanagement.vue')
            },
            {
                // 出入记录
                path: 'Entryandexitrecords',
                component: () => import('../views/Entryandexitrecords.vue'),
                children: [
                    {
                        // 车辆出入记录
                        path: 'Vehiclerecords',
                        component: () => import('../views/Vehiclerecords.vue')
                    },
                    {
                        // 人员出入记录
                        path: 'Personnelrecords',
                        component: () => import('../views/Personnelrecords.vue')
                    }
                ]
            },
            {
                // 业主信息查看
                path: 'OwnerInformations',
                component: () => import('../views/OwnerInformations.vue'),
                children: [
                    {
                        // 业主信息
                        path: 'OwnerInformation',
                        component: () => import('../views/OwnerInformation.vue')
                    },
                    {
                        // 房屋信息
                        path: 'Houseinformation',
                        component: () => import('../views/Houseinformation.vue')
                    },
                    {
                        // 成员信息
                        path: 'Memberinformation',
                        component: () => import('../views/Memberinformation.vue')
                    },
                    {
                        // 储藏室信息
                        path: 'StorageRoomInformation',
                        component: () => import('../views/StorageRoomInformation.vue')
                    },
                    {
                        // 车位信息
                        path: 'Parkingspaceinformation',
                        component: () => import('../views/Parkingspaceinformation.vue')
                    },
                ]
            },
            {
                // 收费项目
                path: 'Chargeitems',
                component: () => import('../views/Chargeitems.vue')
            },
            {
                // 添加项目
                path: 'Addproject',
                component: () => import('../views/Addproject.vue')
            },
            {
                // 抄表账单
                path: 'Meterreadingbill',
                component: () => import('../views/Meterreadingbill.vue')
            },
            {
                // 添加抄表
                path: 'Addmeterreading',
                component: () => import('../views/Addmeterreading.vue')
            },
            {
                // 费用统计
                path: 'Coststatistics',
                component: () => import('../views/Coststatistics.vue')
            },
            {
                // 成员登记
                path:'MemberRegistration',
                component: () => import('../views/MemberRegistration.vue')
            },
            {
                //组织架构
                path: 'Organizationalstructure',
                component: () => import('../views/Organizationalstructure.vue')
            },
            {
                // 员工管理
                path: 'Staffmanagement',
                component:() => import('../views/Staffmanagement.vue')
            },
            {
                // 角色管理
                path:'Rolesmanagement',
                component: () => import('../views/Rolesmanagement.vue')
            },
            {
                // 基本信息
                path:'Basicinformation',
                component:() => import('../views/Basicinformation.vue')
            },
            {
                // 操作日志
                path:'OperationLog',
                component:() => import('../views/OperationLog.vue')
            },
            {
                // 硬件管理
                path:'Hardwaremanagement',
                component: () => import('../views/Hardwaremanagement.vue')
            },
            {
                // 硬件分类
                path:'Hardwareclassification',
                component: () => import('../views/Hardwareclassification.vue')
            },
            {
                // 停车场管理
                path:'parkingmanagement',
                component: () => import('../views/parkingmanagement.vue')
            },
            {
                // 车位管理
                path:'parkinglotmange',
                component: () => import('../views/parkinglotmange.vue')
            },
            {
                // 月卡管理
                path:'MonthlyCardManagement',
                component: () => import('../views/MonthlyCardManagement.vue')
            },
            {
                // 停车记录
                path:'Parkingrecord',
                component: () => import('../views/Parkingrecord.vue')
            },
            {
                // 门禁管理
                path:'Accesscontrol',
                component: () => import('../views/Accesscontrol.vue')
            },
            {
                // 业主审核
                path:'Ownerreview',
                component: () => import('../views/Ownerreview.vue')
            },
            {
                // 通行记录
                path:'Travelrecord',
                component: () => import('../views/Travelrecord.vue')
            },
            {
                // 添加硬件
                path:'Addhardware',
                component: () => import('../views/Addhardware.vue')
            },
            {
                // 添加停车场
                path:'Addparkinglot',
                component:() => import('../views/Addparkinglot.vue')
            },
            {
                // 智能停车车位管理
                path:'Addparkingposion',
                component: () => import('../views/Addparkingposion.vue')
            },
            {
                // 添加停车月卡
                path:'Addmonthlycard',
                component: () => import('../views/Addmonthlycard.vue')
            },
            {
                // 门禁管理添加门禁
                path:'Addaccesscontrol',
                component: () => import('../views/Addaccesscontrol.vue')
            },
            {
                // 配置WIFI
                path:'ConfigurationWIFI',
                component: () => import('../views/ConfigurationWIFI.vue')
            },
            {
                // 门禁管理出入记录
                path:'Entryexitrecords',
                component:() => import('../views/Entryexitrecords.vue')
            },
            {
                // 二维码
                path:'Qrcode',
                component:()=>import('../views/qrcode.vue')
            },
            {
                // 访客开门记录
                path:'doorcords',
                component: () => import('../views/DoorCords.vue')
            },
            {
                // 加密
                path:'code',
                component: () => import('../views/Code.vue')
            }
        ]
    }
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

router.beforeEach((to,from,next)=>{
    // console.log(to,from)
    if(to.matched.some(item=>item.meta.auth==true)){
        if(localStorage.getItem('ticket')){
            next()
        }else{
            next('/')
        }
    }else{
        next()
    }
    // next()
})


export default router
